from django.db import models


# 首页Banner轮播图模型
class BannerModel(models.Model):
    # 字段声明
    title = models.CharField(max_length=255, verbose_name='标题')
    img_url = models.ImageField(max_length=255, verbose_name='图片地址', upload_to='banner')
    link = models.CharField(max_length=255, verbose_name='链接地址')
    remark = models.CharField(max_length=500, verbose_name='备注信息')
    is_show = models.BooleanField(default=False, verbose_name='是否显示')
    is_deleted = models.BooleanField(default=False, verbose_name='是否删除')
    orders = models.IntegerField(default=1, verbose_name='显示优先级')

    # 表信息声明
    class Meta:
        db_table = 'banner'
        verbose_name = '轮播图表'
        verbose_name_plural = verbose_name

    # 自定义方法
    def __str__(self):
        return self.title
